import os
from dotenv import load_dotenv

load_dotenv()

class Config:
    # Flask Configuration
    SECRET_KEY = os.getenv('SECRET_KEY', 'your-secret-key-change-this')
    DEBUG = True
    
    # MongoDB Configuration
    MONGODB_URI = 'mongodb://kb_user:123456@localhost:27017/medical_regulatory_kb'
    DB_NAME = 'medical_regulatory_kb'
    
    # File Upload Configuration
    UPLOAD_FOLDER = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'uploads')
    PDF_FOLDER = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static/pdfs')
    MAX_CONTENT_LENGTH = 50 * 1024 * 1024  # 50MB max file size
    ALLOWED_EXTENSIONS = {'pdf', 'doc', 'docx'}
    
    # DeepSeek API Configuration
    DEEPSEEK_API_KEY = os.getenv('DEEPSEEK_API_KEY', 'your-deepseek-api-key')
    DEEPSEEK_BASE_URL = 'https://api.deepseek.com'
    DEEPSEEK_MODEL = 'deepseek-chat'
    
    # FDA openFDA API Configuration
    FDA_API_KEY = os.getenv('FDA_API_KEY', '')  # Optional: Get from https://open.fda.gov/apis/authentication/
    FDA_BASE_URL = 'https://api.fda.gov'
    FDA_DATE_RANGE = '[2010-01-01+TO+2025-12-31]'
    FDA_DEFAULT_PRODUCT_CODES = ['OHV', 'GEX', 'GEI', 'ONG', 'QAI', 'NGX', 'PBX']
    FDA_REQUEST_TIMEOUT = 10  # seconds
    FDA_RATE_LIMIT_DELAY = 0.25  # seconds between requests
    
    # ModelScope Configuration
    MODELSCOPE_CACHE = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'modelscope_cache')
    EMBEDDING_MODEL = 'damo/nlp_corom_sentence-embedding_english-base'
    
    # Language Support
    SUPPORTED_LANGUAGES = ['en', 'zh', 'pt', 'ja']
    
    # Collections Configuration
    COLLECTIONS = {
        'FDA': {
            'name': 'FDA',
            'display_name': 'US FDA',
            'color': 'blue',
            'description': 'US FDA regulations, guidances, and submission requirements'
        },
        'NMPA': {
            'name': 'NMPA', 
            'display_name': 'China NMPA',
            'color': 'red',
            'description': 'NMPA requirements and registration documentation'
        },
        'PMDA': {
            'name': 'PMDA',
            'display_name': 'Japan PMDA', 
            'color': 'green',
            'description': 'PMDA approval and compliance documentation'
        },
        'ANVISA': {
            'name': 'ANVISA',
            'display_name': 'Brazil ANVISA',
            'color': 'purple', 
            'description': 'ANVISA registration materials and regulations'
        }
    }
    
    # WeChat Configuration
    """
    WECHAT_APP_ID = os.getenv('WECHAT_APP_ID', '')
    WECHAT_APP_SECRET = os.getenv('WECHAT_APP_SECRET', '')
    WECHAT_TOKEN = os.getenv('WECHAT_TOKEN', '')
    """

# Create necessary directories
os.makedirs(Config.UPLOAD_FOLDER, exist_ok=True)
os.makedirs(Config.PDF_FOLDER, exist_ok=True)
os.makedirs(Config.MODELSCOPE_CACHE, exist_ok=True)